package com.ruoyi.project.param.paeaParaSystem.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.param.paeaParaSystem.domain.PaeaParaSystem;
import com.ruoyi.project.param.paeaParaSystem.service.IPaeaParaSystemService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * 文档服务器信息Controller
 *
 * @author 关晓强
 * @date 2020-03-14
 */
@Controller
@RequestMapping("/param/paeaParaSystem")
public class PaeaParaSystemController extends BaseController
{
    private String prefix = "param/paeaParaSystem";

    @Autowired
    private IPaeaParaSystemService paeaParaSystemService;

    @RequiresPermissions("param:paeaParaSystem:view")
    @GetMapping()
    public String paeaParaSystem()
    {
        return prefix + "/paeaParaSystem";
    }

    /**
     * 查询文档服务器信息列表
     */
    @RequiresPermissions("param:paeaParaSystem:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaParaSystem paeaParaSystem)
    {
        startPage();
        List<PaeaParaSystem> list = paeaParaSystemService.list(new QueryWrapper<PaeaParaSystem>(paeaParaSystem));
        return getDataTable(list);
    }

    /**
     * 导出文档服务器信息列表
     */
    @RequiresPermissions("param:paeaParaSystem:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaParaSystem paeaParaSystem)
    {
        List<PaeaParaSystem> list = paeaParaSystemService.list(new QueryWrapper<PaeaParaSystem>(paeaParaSystem));
        ExcelUtil<PaeaParaSystem> util = new ExcelUtil<PaeaParaSystem>(PaeaParaSystem.class);
        return util.exportExcel(list, "paeaParaSystem");
    }

    /**
     * 新增文档服务器信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存文档服务器信息
     */
    @RequiresPermissions("param:paeaParaSystem:add")
    @Log(title = "文档服务器信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaParaSystem paeaParaSystem)
    {
        return toAjax(paeaParaSystemService.saveOrUpdate(paeaParaSystem));
    }

    /**
     * 修改文档服务器信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaParaSystem paeaParaSystem = paeaParaSystemService.getById(id);
        mmap.put("paeaParaSystem", paeaParaSystem);
        return prefix + "/edit";
    }

    /**
     * 修改保存文档服务器信息
     */
    @RequiresPermissions("param:paeaParaSystem:edit")
    @Log(title = "文档服务器信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaParaSystem paeaParaSystem)
    {
        return toAjax(paeaParaSystemService.saveOrUpdate(paeaParaSystem));
    }

    /**
     * 删除文档服务器信息
     */
    @RequiresPermissions("param:paeaParaSystem:remove")
    @Log(title = "文档服务器信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaParaSystemService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
